package com.cyt.chattlibrary.face;/**
 * Created by cpoopc on 2015/9/1.
 */

import android.content.Context;
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;


/**
 * 显示单个表情view
 * User: cpoopc
 * Date: 2015-09-01
 * Time: 18:31
 * Ver.: 0.1
 */
public class EmotionView extends AppCompatImageView {

    public EmotionView(Context context) {
        super(context);
        init();
    }

    private void init() {
        setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    }

    public EmotionView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public EmotionView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        View parent = (View) getParent();
        if (parent != null) {
            setMeasuredDimension(View.MeasureSpec.getSize(widthMeasureSpec), parent.getHeight() == 0 ? 0 : parent.getHeight() / 3);
//            DebugLog.e("--"+(parent.getHeight() == 0 ? 0 : parent.getHeight() / 3));
        } else {
            setMeasuredDimension(View.MeasureSpec.getSize(widthMeasureSpec), getMeasuredHeight());
        }
    }
}
